package views;

/**
 * EDCParseViewer
 * Viewer for analyzing DTD files
 */
import io.FileControler;
import io.XMLControler;

import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.Dimension;
import java.awt.Graphics;
import java.io.File;

import parser.Parser;

import javax.swing.JScrollPane;
import javax.swing.JTextArea;

import utils.EDCResource;
import utils.EDCUtils;

public class EDCParseViewer extends EDCDefaultViewer {
	
	private static final long serialVersionUID = 1L;
	private JTextArea textArea;
	private String contents ="";
	private Parser parser = new Parser();
	
	public EDCParseViewer(String fileName) {	
		setTitle("DTD File Analyzer");
		getContentPane().setLayout(new BorderLayout());
        textArea = new JTextArea(20, 20);
        textArea.setEditable(false);
        JScrollPane scrollPane = new JScrollPane(textArea);
        scrollPane.setPreferredSize(new Dimension(300,300));
        
        parser = new Parser();
        try {
			EDCResource.setInput(EDCResource.inputFile+File.separator+fileName);
		} catch (Exception e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
        parser.parseDTDs();
        
//        try {
//			XMLControler.readXMLFile("log.xml");
//			if(!XMLControler.isXMLContainsFile(fileName)){
//				System.out.println("Parsing");
////				File file = new File(EDCResource.dtdFolderPath+File.separator+fileName);
//				File file = new File(EDCResource.inputFile, fileName);
//				parser.checkDTD(file);
//			}
//		} catch (Exception e) {
//			// TODO Auto-generated catch block
//			e.printStackTrace();
//		}
//        
//        contents = EDCUtils.getRender(fileName);
        textArea.setText(parser.getSBuffer().toString());
        textArea.setCaretPosition(0);
        getContentPane().add(scrollPane, BorderLayout.CENTER);
	}
}
